package com.多线程07.demo23;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class ThreadPoolDemo02 {

    public static void main(String[] args) throws InterruptedException {
        //创建指定大小的线程池对象，参数是最大值，而非初始值
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        ThreadPoolExecutor pool = (ThreadPoolExecutor)executorService;

        System.out.println(pool.getPoolSize());

        //借助executorService向池中放对象
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"zai执行");
        });

        Thread.sleep(5000);

        //借助executorService向池中放对象
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"zai执行");
        });

        System.out.println(pool.getPoolSize());


    }


}
